﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MINERP.BLL.PrintManage;
using MINERP.MODEL.FoundationModel;

namespace MINERP.Frontier
{
    public partial class FrmPaperTitle : Form
    {
        PrinterBLL printerbll = new PrinterBLL();
        public int printerid;
        
        public FrmPaperTitle()
        {
            InitializeComponent();
        }

        private void txtPaperTitle_Enter(object sender, EventArgs e)
        {
            btnOk.PerformClick();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtPaperTitle.Text.Trim()))
            {
                MessageBox.Show("请输入纸头长度","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
                txtPaperTitle.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txtBoxNo.Text.Trim()))
            {
                MessageBox.Show("请输入纸箱号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtBoxNo.Focus();
                return;
            }
            if (printerbll.IsExistPrinterBoxNo(printerid, Convert.ToInt32(txtBoxNo.Text.Trim())))
            {
                ((FrmChangePaper)(this.Owner)).PaperTitle = Convert.ToDouble(txtPaperTitle.Text) / 100;
                ((FrmChangePaper)(this.Owner)).BoxNo = Convert.ToInt32(txtBoxNo.Text.Trim());
                this.Close();
            }
            else
            {
                MessageBox.Show("错误的纸箱号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtBoxNo.Focus();
            }
        }

        private void FrmPaperTitle_Load(object sender, EventArgs e)
        {
            txtBoxNo.Focus();
        }
    }
}
